#include "swpsimsplitgraphicitem.h"

#include "graphicitemcommon.h"

using namespace core;
using namespace swp;

SwpSimSplitGraphicItem::SwpSimSplitGraphicItem(QGraphicsItem* parent) :
    SwpSplitGraphicItem(parent), ISimItem(),
    m_isInSimPath(false),
    m_originId()
{
    setFlag(QGraphicsItem::ItemIsMovable, false);
}

SwpSimSplitGraphicItem::SwpSimSplitGraphicItem(SwpSplitGraphicItem* from,
    QGraphicsItem* parent) : SwpSplitGraphicItem(parent), ISimItem(),
        m_isInSimPath(false),
        m_originId(from->id())
{
    setFlag(QGraphicsItem::ItemIsMovable, false);

    setPos(from->pos());
}

SwpSimSplitGraphicItem::~SwpSimSplitGraphicItem()
{

}

bool SwpSimSplitGraphicItem::supportsConnection(
        const ConnectionData& connection) const
{
    return connection.ConnectionId == CONNECTION_SIM_PATH;
}

int SwpSimSplitGraphicItem::type() const
{
    return SWP_SIM_SPLIT_ITEM;
}

IEditorItem* SwpSimSplitGraphicItem::copy() const
{
    return new SwpSimSplitGraphicItem();
}

bool SwpSimSplitGraphicItem::isInSimPath() const
{
    return m_isInSimPath;
}

void SwpSimSplitGraphicItem::setInSimPath(bool in)
{
    if (in)
    {
        setBrush(QBrush(m_palette->acceptsConnectionColor()));
    }
    else
    {
        setBrush(QBrush(m_palette->borderColor()));
    }

    m_isInSimPath = in;
}

QUuid SwpSimSplitGraphicItem::originId() const
{
    return m_originId;
}
